package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-08-16
 * Time: 15:48
 */
public class Demo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            while (true) {
                System.out.println("hello world");
            }
        });
        t.setDaemon(true);
        t.start();
        //Thread.sleep(1000);

        //并发，前台main线程结束，后台Thread线程也结束。
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
